package com.controller;

import com.orm.Db;
import com.orm.UserEntity;

import java.sql.ResultSet;
import java.util.ArrayList;

/**
 * Created by lirance on 16/5/10.
 */
public class GetUsersList {
    public ArrayList GetUserLists() throws Exception {
        String sql = "select * from user";
        ArrayList<UserEntity> serviceCalls = new ArrayList<>();

        ResultSet resultSet = Db.getInstance().executeQuery(sql);
        int i = 0;
        while (resultSet.next() && i <= 1000) {
            i++;
            UserEntity serCall = new UserEntity();
            serCall.setuId(resultSet.getInt("uId"));
            serCall.setIp(resultSet.getString("ip"));
            serCall.setcName(resultSet.getString("CName"));
            serCall.setdName(resultSet.getString("dName"));
            serviceCalls.add(serCall);
        }
        resultSet.close();
        return serviceCalls;
    }

}
